Make it possible to set which type of queue to be created RabbitMQ let you use different kinds of queues. Letting you configure which type of queues the subscribers use should be given. Change-Id: Ifcd3a9ac630495772aedd7b34ea6bf3708aef49c
diff --git a/src/main/java/com/googlesource/gerrit/plugins/rabbitmq/config/section/AMQP.java b/src/main/java/com/googlesource/gerrit/plugins/rabbitmq/config/section/AMQP.java index 7b001fd..de9bed4 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/rabbitmq/config/section/AMQP.java +++ b/src/main/java/com/googlesource/gerrit/plugins/rabbitmq/config/section/AMQP.java
@@ -40,4 +40,6 @@ @Default("300") public Integer consumerPrefetch; + + @Default public String queueType; } diff --git a/src/main/java/com/googlesource/gerrit/plugins/rabbitmq/session/type/AMQPSubscriberSession.java b/src/main/java/com/googlesource/gerrit/plugins/rabbitmq/session/type/AMQPSubscriberSession.java index d19e023..4e2fc00 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/rabbitmq/session/type/AMQPSubscriberSession.java +++ b/src/main/java/com/googlesource/gerrit/plugins/rabbitmq/session/type/AMQPSubscriberSession.java
@@ -69,7 +69,7 @@ try { channel.basicQos(amqp.consumerPrefetch > 0 ? amqp.consumerPrefetch : 0); - } catch(IOException ex) { + } catch (IOException ex) { logger.atSevere().withCause(ex).log("Error when trying to set consumer prefetch"); } @@ -79,7 +79,13 @@ String queueName; if (!amqp.queuePrefix.isEmpty()) { queueName = amqp.queuePrefix + "." + topic; - channel.queueDeclare(queueName, amqp.durable, amqp.exclusive, amqp.autoDelete, null); + + channel.queueDeclare( + queueName, + amqp.durable, + amqp.exclusive, + amqp.autoDelete, + !amqp.queueType.isEmpty() ? Map.of("x-queue-type", amqp.queueType) : null); } else { queueName = channel.queueDeclare().getQueue(); } diff --git a/src/main/resources/Documentation/config.md b/src/main/resources/Documentation/config.md index 54cdee8..eaa5fef 100644 --- a/src/main/resources/Documentation/config.md +++ b/src/main/resources/Documentation/config.md
@@ -75,6 +75,11 @@ prefix + '.' + topic, otherwise the queues will get a random name decided by RabbitMQ. Only used in broker.config. +* `amqp.queueType` + * Specify type of queue to be created. Either `quorum` or `classic`. If not set the queue will + get the type default for the RabbitMQ instance. Only used in broker.config and is only used if + `amqp.queuePrefix` is specified. + * `amqp.durable` * Make queues persistant on disk. So they stick even after a restart of RabbitMQ. Only used in broker.config and is only used if `amqp.queuePrefix` is specified.